﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SQLite;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace itChatAdmin
{
    public partial class FormLogView : Form
    {
        public FormLogView(String ID)
        {
            InitializeComponent();

            SetValue(ID);
        }
        private void SetValue(String ID)
        {
            SQLiteCommand mySQLiteCommand = new SQLiteCommand("", Form1.memSQLiteConnection);
            mySQLiteCommand.CommandText = "SELECT * FROM MelaSendMsgLog WHERE ID=@ID";
            mySQLiteCommand.Parameters.Add(new SQLiteParameter("@ID"));
            mySQLiteCommand.Parameters["@ID"].Value = ID;

            SQLiteDataReader mySQLiteDataReader = mySQLiteCommand.ExecuteReader();
            if (mySQLiteDataReader.Read())
            {
                this.textBox1.Text = mySQLiteDataReader["NickName"].ToString().Trim();
                this.textBox2.Text = mySQLiteDataReader["UpdateDataTime"].ToString().Trim();
                this.textBox3.Text = mySQLiteDataReader["SendResult"].ToString().Trim();
                this.textBox4.Text = mySQLiteDataReader["SendMsg"].ToString().Trim();
                //this.textBox5.Text = Form1.ConvertJsonString(mySQLiteDataReader["RawResult"].ToString().Trim());
                this.textBox5.Text = mySQLiteDataReader["RawResult"].ToString().Trim();
                toolTip1.ToolTipIcon = ToolTipIcon.Info;
                toolTip1.ToolTipTitle = "微信服务器返回消息";
                //toolTip1.IsBalloon = true;
                toolTip1.UseFading = true;
            }
            mySQLiteDataReader.Close();
        }

        private void textBox5_MouseEnter(object sender, EventArgs e)
        {
            this.toolTip1.Show(Form1.ConvertJsonString(this.textBox5.Text), this.textBox5);
        }

        private void textBox5_MouseLeave(object sender, EventArgs e)
        {
            this.toolTip1.Hide(this.textBox5);
        }
    }
}
